﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;

namespace SharpSqlAnalyzer
{
	// Token: 0x0200004B RID: 75
	internal class TLexerHive : TCustomLexer
	{
		// Token: 0x06000108 RID: 264 RVA: 0x00016A7B File Offset: 0x00014C7B
		static TLexerHive()
		{
			TLexerHive.table_file = "/SharpSqlAnalyzer/parser/hive/hive_lex_table.txt";
			TLexerHive.inittable();
		}

		// Token: 0x06000109 RID: 265 RVA: 0x00016AA6 File Offset: 0x00014CA6
		internal TLexerHive()
		{
			this.dbvendor = EDbVendor.dbvhive;
			this.sourcetokens = new TSourceTokenList();
		}

		// Token: 0x0600010A RID: 266 RVA: 0x00016AC0 File Offset: 0x00014CC0
		public static bool canBeColumnName(int tokencode)
		{
			return TCustomLexer.canBeColumnName(tokencode, TLexerHive.keywordTypeList);
		}

		// Token: 0x0600010B RID: 267 RVA: 0x00016ACD File Offset: 0x00014CCD
		public static int iskeyword(string str)
		{
			return TCustomLexer.iskeyword(str, TLexerHive.keywordValueList);
		}

		// Token: 0x0600010C RID: 268 RVA: 0x00016ADA File Offset: 0x00014CDA
		public static int getkeywordvalue(string keyword)
		{
			return TCustomLexer.getkeywordvalue(keyword, TLexerHive.keywordValueList);
		}

        // Token: 0x0600010D RID: 269 RVA: 0x00016AE8 File Offset: 0x00014CE8
        internal override int yylex()
        {
            do
            {
                yynew();
                while (true)
                {
                    int i;
                    for (i = yykl[yystate]; i <= yykh[yystate]; i++)
                    {
                        yymark(yyk[i]);
                    }
                    for (i = yymh[yystate]; i >= yyml[yystate]; i--)
                    {
                        yymatch(yym[i]);
                    }
                    if (yytl[yystate] > yyth[yystate])
                    {
                        break;
                    }
                    yyscan();
                    i = yytl[yystate];
                    totablechar();
                    for (; i <= yyth[yystate] && !charinarray(yytablechar, yyt[i].cc); i++)
                    {
                    }
                    if (i > yyth[yystate])
                    {
                        break;
                    }
                    yystate = yyt[i].s;
                }
                do
                {
                    int yyruleno;
                    if ((yyruleno = yyfind()) != -1)
                    {
                        yyaction(yyruleno);
                        continue;
                    }
                    if (!yydefault() && yywrap())
                    {
                        yyclear();
                        returni(0);
                    }
                    break;
                }
                while (yyreject);
            }
            while (!yydone);
            return yyretval;
        }

        // Token: 0x0600010E RID: 270 RVA: 0x00016C2C File Offset: 0x00014E2C
        internal static void inittable()
		{
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			bool flag4 = false;
			bool flag5 = false;
			bool flag6 = false;
			bool flag7 = false;
			bool flag8 = false;
			bool flag9 = false;
			bool flag10 = false;
			bool flag11 = false;
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			int num5 = 0;
			int num6 = 0;
			int num7 = 0;
			int num8 = 0;
			int num9 = 0;
			int num10 = 0;
			int num11 = 0;
			TLexerHive.keywordValueList.Clear();
			TLexerHive.keywordTypeList.Clear();
			StreamReader streamReader = TCustomLexer.readSymbolTable("hive", "lex");
			try
			{
				string text;
				while ((text = streamReader.ReadLine()) != null)
				{
					if (text.Trim().StartsWith("yynmarks=", StringComparison.Ordinal))
					{
						TLexerHive.yynmarks = int.Parse(text.Split(new char[]
						{
							'=',
							';'
						}, StringSplitOptions.RemoveEmptyEntries)[1].Trim());
						TLexerHive.yyk = new int[TLexerHive.yynmarks + 1];
					}
					else if (text.Trim().StartsWith("yynmatches=", StringComparison.Ordinal))
					{
						TLexerHive.yynmatches = int.Parse(text.Split(new char[]
						{
							'=',
							';'
						}, StringSplitOptions.RemoveEmptyEntries)[1].Trim());
						TLexerHive.yym = new int[TLexerHive.yynmatches + 1];
					}
					else if (text.Trim().StartsWith("yyntrans=", StringComparison.Ordinal))
					{
						TLexerHive.yyntrans = int.Parse(text.Split(new char[]
						{
							'=',
							';'
						}, StringSplitOptions.RemoveEmptyEntries)[1].Trim());
						TLexerHive.yytint = new int[TLexerHive.yyntrans + 1];
						TLexerHive.yyt = new TYytRec[TLexerHive.yyntrans + 1];
					}
					else if (text.Trim().StartsWith("yynstates=", StringComparison.Ordinal))
					{
						TLexerHive.yynstates = int.Parse(text.Split(new char[]
						{
							'=',
							';'
						}, StringSplitOptions.RemoveEmptyEntries)[1].Trim());
						TLexerHive.yykl = new int[TLexerHive.yynstates];
						TLexerHive.yykh = new int[TLexerHive.yynstates];
						TLexerHive.yyml = new int[TLexerHive.yynstates];
						TLexerHive.yymh = new int[TLexerHive.yynstates];
						TLexerHive.yytl = new int[TLexerHive.yynstates];
						TLexerHive.yyth = new int[TLexerHive.yynstates];
					}
					else if (text.Trim().StartsWith("<end>", StringComparison.Ordinal))
					{
						if (flag)
						{
							flag = false;
							if (TLexerHive.yynmarks + 1 != num)
							{
								Console.WriteLine("required1:" + TLexerHive.yynmarks.ToString() + " actually:" + (num - 1).ToString());
							}
						}
						else if (flag2)
						{
							flag2 = false;
							if (TLexerHive.yynmatches + 1 != num2)
							{
								Console.WriteLine("required2:" + TLexerHive.yynmatches.ToString() + " actually:" + (num2 - 1).ToString());
							}
						}
						else if (flag3)
						{
							flag3 = false;
							if (TLexerHive.yynstates != num3)
							{
								Console.WriteLine("required3:" + TLexerHive.yynstates.ToString() + " actually:" + num3.ToString());
							}
						}
						else if (flag4)
						{
							flag4 = false;
							if (TLexerHive.yynstates != num4)
							{
								Console.WriteLine("required4:" + TLexerHive.yynstates.ToString() + " actually:" + num4.ToString());
							}
						}
						else if (flag5)
						{
							flag5 = false;
							if (TLexerHive.yynstates != num5)
							{
								Console.WriteLine("required5:" + TLexerHive.yynstates.ToString() + " actually:" + num5.ToString());
							}
						}
						else if (flag6)
						{
							flag6 = false;
							if (TLexerHive.yynstates != num6)
							{
								Console.WriteLine("required:" + TLexerHive.yynstates.ToString() + " actually:" + num6.ToString());
							}
						}
						else if (flag7)
						{
							flag7 = false;
							if (TLexerHive.yynstates != num7)
							{
								Console.WriteLine("required6:" + TLexerHive.yynstates.ToString() + " actually:" + num7.ToString());
							}
						}
						else if (flag8)
						{
							flag8 = false;
							if (TLexerHive.yynstates != num8)
							{
								Console.WriteLine("required7:" + TLexerHive.yynstates.ToString() + " actually:" + num8.ToString());
							}
						}
						else if (flag9)
						{
							flag9 = false;
							if (TLexerHive.yyntrans + 1 != num9)
							{
								Console.WriteLine("required8:" + TLexerHive.yyntrans.ToString() + " actually:" + (num9 - 1).ToString());
							}
						}
						else if (flag10)
						{
							flag10 = false;
							if (TLexerHive.yyntrans + 1 != num10)
							{
								Console.WriteLine("required9:" + TLexerHive.yyntrans.ToString() + " actually:" + (num10 - 1).ToString());
							}
						}
						else if (flag11)
						{
							flag11 = false;
						}
					}
					else if (text.Trim().StartsWith("yyk =", StringComparison.Ordinal))
					{
						flag = true;
					}
					else if (text.Trim().StartsWith("yym =", StringComparison.Ordinal))
					{
						flag2 = true;
					}
					else if (text.Trim().StartsWith("yykl =", StringComparison.Ordinal))
					{
						flag3 = true;
					}
					else if (text.Trim().StartsWith("yykh =", StringComparison.Ordinal))
					{
						flag4 = true;
					}
					else if (text.Trim().StartsWith("yyml =", StringComparison.Ordinal))
					{
						flag5 = true;
					}
					else if (text.Trim().StartsWith("yymh =", StringComparison.Ordinal))
					{
						flag6 = true;
					}
					else if (text.Trim().StartsWith("yytl =", StringComparison.Ordinal))
					{
						flag7 = true;
					}
					else if (text.Trim().StartsWith("yyth =", StringComparison.Ordinal))
					{
						flag8 = true;
					}
					else if (text.Trim().StartsWith("yytint =", StringComparison.Ordinal))
					{
						flag9 = true;
					}
					else if (text.Trim().StartsWith("yyt =", StringComparison.Ordinal))
					{
						flag10 = true;
					}
					else if (text.Trim().StartsWith("keywordsvalue =", StringComparison.Ordinal))
					{
						flag11 = true;
					}
					else if (flag)
					{
						string[] array = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int i = 0; i < array.Length; i++)
						{
							TLexerHive.yyk[num++] = int.Parse(array[i].Trim());
						}
					}
					else if (flag2)
					{
						string[] array2 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int j = 0; j < array2.Length; j++)
						{
							TLexerHive.yym[num2++] = int.Parse(array2[j].Trim());
						}
					}
					else if (flag3)
					{
						string[] array3 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int k = 0; k < array3.Length; k++)
						{
							TLexerHive.yykl[num3++] = int.Parse(array3[k].Trim());
						}
					}
					else if (flag4)
					{
						string[] array4 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int l = 0; l < array4.Length; l++)
						{
							TLexerHive.yykh[num4++] = int.Parse(array4[l].Trim());
						}
					}
					else if (flag5)
					{
						string[] array5 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int m = 0; m < array5.Length; m++)
						{
							TLexerHive.yyml[num5++] = int.Parse(array5[m].Trim());
						}
					}
					else if (flag6)
					{
						string[] array6 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int n = 0; n < array6.Length; n++)
						{
							TLexerHive.yymh[num6++] = int.Parse(array6[n].Trim());
						}
					}
					else if (flag7)
					{
						string[] array7 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int num12 = 0; num12 < array7.Length; num12++)
						{
							TLexerHive.yytl[num7++] = int.Parse(array7[num12].Trim());
						}
					}
					else if (flag8)
					{
						string[] array8 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int num13 = 0; num13 < array8.Length; num13++)
						{
							TLexerHive.yyth[num8++] = int.Parse(array8[num13].Trim());
						}
					}
					else if (flag9)
					{
						string[] array9 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int num14 = 0; num14 < array9.Length; num14++)
						{
							TLexerHive.yytint[num9++] = int.Parse(array9[num14].Trim());
						}
					}
					else if (flag10)
					{
						num11 = 0;
						string[] array10 = text.Trim().Split(new string[]
						{
							",,"
						}, StringSplitOptions.RemoveEmptyEntries);
						char[] array11 = new char[array10.Length];
						for (int num15 = 0; num15 < array10.Length; num15++)
						{
							if (array10[num15].StartsWith("'", StringComparison.Ordinal))
							{
								if (array10[num15].Length == 3)
								{
									array11[num11++] = array10[num15][1];
								}
								else if (array10[num15].Length == 4)
								{
									array11[num11++] = array10[num15][2];
								}
								else
								{
									Console.WriteLine(" read yytstr error, error string is " + array10[num15] + "line: " + num10.ToString());
								}
							}
							else
							{
								try
								{
									array11[num11++] = (char)int.Parse(array10[num15]);
								}
								catch (FormatException ex)
								{
									Console.WriteLine("NumberFormatException: " + ex.Message);
								}
							}
						}
						TLexerHive.yyt[num10] = new TYytRec(array11, TLexerHive.yytint[num10]);
						num10++;
					}
					else if (flag11)
					{
						string[] array12 = text.Split(new char[]
						{
							'='
						}, StringSplitOptions.RemoveEmptyEntries);
						TLexerHive.keywordValueList[array12[0].ToUpper()] = int.Parse(array12[1]);
						TLexerHive.keywordTypeList[int.Parse(array12[1])] = int.Parse(array12[2]);
					}
				}
			}
			catch (IOException ex2)
			{
				Console.WriteLine(ex2.ToString());
			}
		}

		// Token: 0x0600010F RID: 271 RVA: 0x0001766C File Offset: 0x0001586C
		internal override void yyaction(int yyruleno)
		{
            //RuntimeHelpers.InitializeArray(new char[7], fieldof(<PrivateImplementationDetails>.C26324E724DBE67E9EA29B8827462613F2AA946EA1F4E3BB44FC3C4B1CA81F4E).FieldHandle);
            _ = new char[7] { '=', '+', '-', '*', '/', '>', '<' };
            this.yylvalstr = this.getyytext();
			switch (yyruleno)
			{
			case 1:
				this.start(2);
				this.addlit(this.yylvalstr, this.yytextlen);
				this.yylvalstr = this.litbufdup();
				this.returni(275);
				return;
			case 2:
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 3:
				if (this.yysstate == 6)
				{
					this.addlit(this.yylvalstr, this.yytextlen);
					return;
				}
				this.start(8);
				this.startlit();
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 4:
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 5:
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 6:
				this.dummych1 = this.get_char();
				this.addlit(this.yylvalstr + this.dummych1.ToString(), this.yytextlen + 1);
				return;
			case 7:
				this.dummych1 = this.get_char();
				this.addlit(this.yylvalstr + this.dummych1.ToString(), this.yytextlen + 1);
				return;
			case 8:
				this.start(2);
				this.addlit(this.yylvalstr, this.yytextlen);
				if (this.literallen == 0)
				{
					this.returni(274);
				}
				if (this.literallen >= 255)
				{
					this.setlengthofliteralbuf(255);
					this.literallen = 255;
				}
				this.yylvalstr = this.litbufdup();
				this.returni(275);
				return;
			case 9:
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 10:
				this.start(6);
				this.startlit();
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 11:
				this.dummych1 = this.get_char();
				this.unget_char(this.dummych1);
				if (this.dummych1 == '\n')
				{
					this.dummych1 = this.get_char();
					this.addlit(this.yylvalstr + this.dummych1.ToString(), this.yytextlen + 1);
					return;
				}
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 12:
				this.returni(260);
				return;
			case 13:
				this.returni(259);
				return;
			case 14:
				if (this.getyysstate() == 8 || this.getyysstate() == 6)
				{
					this.addlit(this.yylvalstr, 1);
					this.yyless(1);
					return;
				}
				this.returni(258);
				return;
			case 15:
				this.returni(46);
				return;
			case 16:
				this.returni(58);
				return;
			case 17:
				this.returni(44);
				return;
			case 18:
				this.returni(59);
				return;
			case 19:
				this.returni(40);
				return;
			case 20:
				this.returni(41);
				return;
			case 21:
				this.returni(91);
				return;
			case 22:
				this.returni(93);
				return;
			case 23:
				this.returni(123);
				return;
			case 24:
				this.returni(125);
				return;
			case 25:
				this.returni(60);
				return;
			case 26:
				this.returni(62);
				return;
			case 27:
				this.returni(47);
				return;
			case 28:
				this.returni(43);
				return;
			case 29:
				this.returni(45);
				return;
			case 30:
				this.returni(42);
				return;
			case 31:
				this.returni(37);
				return;
			case 32:
				this.returni(38);
				return;
			case 33:
				this.returni(126);
				return;
			case 34:
				this.returni(124);
				return;
			case 35:
				this.returni(94);
				return;
			case 36:
				this.returni(63);
				return;
			case 37:
				this.returni(36);
				return;
			case 38:
				this.returni(289);
				return;
			case 39:
				this.returni(288);
				return;
			case 40:
				this.returni(290);
				return;
			case 41:
				this.returni(294);
				return;
			case 42:
				this.returni(33);
				return;
			case 43:
				this.returni(296);
				return;
			case 44:
				this.returni(297);
				return;
			case 45:
				this.returni(293);
				return;
			case 46:
				this.returni(277);
				return;
			case 47:
				this.returni(278);
				return;
			case 48:
				this.returni(279);
				return;
			case 49:
				this.returni(280);
				return;
			case 50:
				this.returni(273);
				return;
			case 51:
				this.returni(272);
				return;
			case 52:
				this.returni(276);
				return;
			case 53:
			{
				int n;
				if ((n = TLexerHive.iskeyword(this.yylvalstr)) != -1)
				{
					this.returni(n);
					return;
				}
				this.returni(264);
				return;
			}
			case 54:
				this.returni(270);
				return;
			case 55:
				this.returni(271);
				return;
			case 56:
				this.returni(274);
				return;
			default:
				Console.WriteLine("fatal error in yyaction");
				return;
			}
		}

		// Token: 0x04000E38 RID: 3640
		internal static int yynmarks = 0;

		// Token: 0x04000E39 RID: 3641
		internal static int yynmatches;

		// Token: 0x04000E3A RID: 3642
		internal static int yyntrans;

		// Token: 0x04000E3B RID: 3643
		internal static int yynstates;

		// Token: 0x04000E3C RID: 3644
		internal static int[] yyk;

		// Token: 0x04000E3D RID: 3645
		internal static int[] yym;

		// Token: 0x04000E3E RID: 3646
		internal static int[] yytint;

		// Token: 0x04000E3F RID: 3647
		internal static TYytRec[] yyt;

		// Token: 0x04000E40 RID: 3648
		internal static int[] yykl;

		// Token: 0x04000E41 RID: 3649
		internal static int[] yykh;

		// Token: 0x04000E42 RID: 3650
		internal static int[] yyml;

		// Token: 0x04000E43 RID: 3651
		internal static int[] yymh;

		// Token: 0x04000E44 RID: 3652
		internal static int[] yytl;

		// Token: 0x04000E45 RID: 3653
		internal static int[] yyth;

		// Token: 0x04000E46 RID: 3654
		private static string[] keywordlist;

		// Token: 0x04000E47 RID: 3655
		internal static string table_file;

		// Token: 0x04000E48 RID: 3656
		internal static IDictionary<string, int> keywordValueList = new Dictionary<string, int>();

		// Token: 0x04000E49 RID: 3657
		internal static IDictionary<int, int> keywordTypeList = new Dictionary<int, int>();

		// Token: 0x04000E4A RID: 3658
		public TSourceTokenList sourcetokens;
	}
}
